
        var exec = require("cordova/exec");
        var scanInProgress = false;

        /**
         * Constructor.
         *
         * @returns {CardScanner}
         */
        function CardScanner() {

            /**
             * Encoding constants.
             *
             * @type Object
             */
            this.TYPE = {
                IDCARD: 1,
                IDJSZCARD: 2,
                IDXSZCARD: 3,
                IDBANK: 4,
                DLPR: 5
            };
  }

/**
 * Read code from scanner.
 *
 * @param options
 * @param {Function} successCallback This function will recieve a result object: {
         *        text : '12345-mock',    // The code that was scanned.
         *        format : 'FORMAT_NAME', // Code format.
         *        cancelled : true/false, // Was canceled.
         *    }
 * @param {Function} errorCallback
 */
CardScanner.prototype.scan = function (options, successCallback, errorCallback) {
            if (!(options instanceof Object)) {
                options = {"type": options};
            }

            if (errorCallback == null) {
                errorCallback = function () {
                };
            }

            if (typeof errorCallback != "function") {
                console.log("CardScanner.scan failure: failure parameter not a function");
                return;
            }

            if (typeof successCallback != "function") {
                console.log("CardScanner.scan failure: success callback parameter must be a function");
                return;
            }

            if (scanInProgress) {
                errorCallback('Scan is already in progress');
                return;
            }

            scanInProgress = true;

            exec(
                function(result) {
                    scanInProgress = false;
                    successCallback(result);
                },
                function(error) {
                    scanInProgress = false;
                    errorCallback(error);
                },
                'CardScanner',
                'scan',
                [options]
            );
        };

        //-------------------------------------------------------------------
        CardScanner.prototype.init = function (successCallback, errorCallback, options) {
            if (successCallback == null) {
            	successCallback = function () {
                };
            }
            if (errorCallback == null) {
                errorCallback = function () {
                };
            }

            if (typeof errorCallback != "function") {
                console.log("CardScanner.init failure: failure parameter not a function");
                return;
            }

            if (typeof successCallback != "function") {
                console.log("CardScanner.init failure: success callback parameter must be a function");
                return;
            }

            exec(successCallback, errorCallback, 'CardScanner', 'init', []);
        };

        var cardScanner = new CardScanner();
        module.exports = cardScanner;

